package com.jycrm.presentation.core.support;

import javax.servlet.http.HttpSession;

import org.apache.tapestry.IEngine;
import org.directwebremoting.WebContextFactory;

public class DirectWebRemoteWebContextFactorySuppot extends WebContextFactory {

	private final static String  TAPESTRY_ENGINE_REGISTER="org.apache.tapestry.engine:";
	
	public final static String  TAPESTRY_SERVLET_NAME="TAPESTRY_SERVLET_NAME";
	
	public static IEngine getTapestryEngine(){
		HttpSession session = get().getSession();
		String tservletName = (String) get().getServletContext().getAttribute(TAPESTRY_SERVLET_NAME);
		String key = TAPESTRY_ENGINE_REGISTER + tservletName;
		IEngine engine = (IEngine) session.getAttribute(key);
		return engine; 
	}
}
